package com.resume.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.resume.constant.GlobalConst;
import com.resume.domain.${className};
import com.resume.mapper.${className}Mapper;
import com.resume.service.${className}Service;
import org.springframework.stereotype.Service;

import java.util.List;

/**
* @Author: 梁云亮
* @Date: 2021/7/14 13:51
* @Describe:
*/
@Service
public class ${className}ServiceImpl extends ServiceImpl<${className}Mapper, ${className}> implements ${className}Service {

    @Override
    public List<${className}> listAllUsable${className}() {
        QueryWrapper<${className}> queryWrapper = new QueryWrapper<>();
        queryWrapper.select("id", "name", "info")
        .eq("status", GlobalConst.Common.STATUS_ENABLE);// 1 表示显示

        List<${className}> ${objName}List = baseMapper.selectList(queryWrapper);
        return ${objName}List;
    }

    @Override
    public boolean modify${className}Status(Integer id, Integer status) {
        ${className} ${objName} = ${className}.builder()
                                    .id(id)
                                    .status(status)
                                    .build();
        int res = baseMapper.updateById(${objName});
        return res == 1 ? true : false;
    }

    @Override
    public boolean modify(${className} ${objName}) {
        QueryWrapper<${className}> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("id",${objName}.getId());
        int updateRes = baseMapper.update(${objName}, queryWrapper);
        return updateRes == 1 ? true : false;
    }

}
